<template>
  <div id="main">
    <h2>教学讨论</h2>

    <div class="head">
      <el-button
        v-if="jurisdiction == '责任教师'"
        type="primary"
        style="margin: 20px"
        @click="handleOpen('添加计划', 1)"
      >添加教学讨论</el-button>
      <el-input
        v-model="searchTableInfo"
        placeholder="请输入搜索内容"
        style="width: 240px; float: right; margin: 20px"
      />
    </div>
    <div id="table-area">
      <el-table
        v-loading="listLoading"
        :data="list.slice((currentPage - 1) * pagesize, currentPage * pagesize)"
        border
        fit
        highlight-current-row
      >
        <el-table-column
          label="序号"
          type="index"
          align="center"
        >
          <template scope="scope">
            <span>{{ (currentPage - 1) * pagesize + scope.$index + 1 }}</span>
          </template>
        </el-table-column>

        <el-table-column
          align="center"
          prop="clazzTypeName"
          label="课程类型"
          :formatter="clazzTypeName_toString"
        />

        <el-table-column
          align="center"
          prop="technicalTypeName"
          label="技术类别"
          :formatter="technicalTypeName_toString"
        />

        <el-table-column
          align="center"
          prop="teachingDiscussionTeacherName"
          label="授课教师"
        />
        <el-table-column
          align="center"
          prop="teachingDiscussionPrincipalTeacherName"
          label="主责老师"
        />
        <el-table-column
          align="center"
          prop="teachingDiscussionTeachingSupervisorName"
          label="教学主管"
        />
        <el-table-column
          align="center"
          prop="teachingDiscussionEventType"
          label="事件类别"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.teachingDiscussionEventType == '0'">计划调整</span>
            <span v-if="scope.row.teachingDiscussionEventType == '1'">方案改进</span>
            <span v-if="scope.row.teachingDiscussionEventType == '2'">寻求帮助</span>
            <span v-if="scope.row.teachingDiscussionEventType == '3'">其他</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="teachingDiscussionPostUserName"
          label="发起人"
        />
        <el-table-column
          align="center"
          prop="teachingDiscussionPostTime"
          label="发起时间"
        />
        <el-table-column
          align="center"
          prop="teachingDiscussionStatus"
          label="状态"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.teachingDiscussionStatus == '0'">发起</span>
            <span v-if="scope.row.teachingDiscussionStatus == '1'">准备</span>
            <span v-if="scope.row.teachingDiscussionStatus == '2'">执行</span>
            <span v-if="scope.row.teachingDiscussionStatus == '3'">结束</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          label="操作"
        >
          <template slot-scope="Scope">
            <el-button
              v-if="
                jurisdiction == '授课老师' ||
                  jurisdiction == '教学主管' ||
                  jurisdiction == '教学主任' ||
                  jurisdiction == '医疗主管'
              "
              type="primary"
              icon="el-icon-search"
              @click="handleOpen('修改计划', 2, Scope.row.teachingDiscussionId)"
            >查看</el-button>
            <el-button
              v-if="jurisdiction == '责任教师' || jurisdiction == '教务主任'"
              type="primary"
              icon="el-icon-edit"
              @click="handleOpen('修改计划', 2, Scope.row.teachingDiscussionId)"
            >编辑</el-button>
            <!-- <el-button type="danger" icon="el-icon-delete" @click="handleDelete(Scope.row.plansId) ">删除</el-button> -->
          </template>
        </el-table-column>
      </el-table>

      <div id="pages">
        <el-pagination
          :current-page="currentPage"
          :page-sizes="[5, 10]"
          :page-size="pagesize"
          layout="total, sizes,prev, pager, next"
          :total="list.length"
          prev-text="上一页"
          next-text="下一页"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </div>

    <el-dialog
      v-if="this.jurisdiction == '责任教师'"
      title=""
      :close-on-click-modal="false"
      :visible.sync="dialogFormVisible"
      :before-close="handleClose"
    >
      <el-form
        ref="teachingDiscussion"
        :model="teachingDiscussion"
        label-position="top"
        :rules="rules"
      >
        <el-form-item
          prop="teachingDiscussionEventType"
          label="事件类别"
          :label-width="formLabelWidth"
        >
          <el-select
            v-model="teachingDiscussion.teachingDiscussionEventType"
            filterable
            placeholder="请选择"
            style="width: 100%"
          >
            <el-option
              v-for="j in options"
              :key="j.value"
              :label="j.label"
              :value="j.value"
            />
          </el-select>
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionEventTitle"
          label="事件标题"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="teachingDiscussion.teachingDiscussionEventTitle"
            autocomplete="off"
            maxlength="20"
            show-word-limit
            style="width: 100%"
          />
        </el-form-item>
        <el-form-item
          prop="teachingDiscussionEventDescription"
          label="事件描述"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="teachingDiscussion.teachingDiscussionEventDescription"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
          />
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionRelatedPersonnelIDs"
          label="参加人员"
          :label-width="formLabelWidth"
        >
          <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
          <el-select
            v-model="teachingDiscussion.teachingDiscussionRelatedPersonnelIDs"
            multiple
            placeholder="请选择"
            filterable
            style="width: 100%"
          >
            <el-option
              v-for="j in staff"
              :key="j.staffId"
              :value="j.staffId"
              :label="j.String"
            />
          </el-select>
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionSolution"
          label="解决方案"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="teachingDiscussion.teachingDiscussionSolution"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
          />
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionExecutionRecord"
          label="执行记录"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="teachingDiscussion.teachingDiscussionExecutionRecord"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
          />
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionEventSummary"
          label="事件总结"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="teachingDiscussion.teachingDiscussionEventSummary"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item
          prop="teachingDiscussionStatus"
          label="状态"
          :label-width="formLabelWidth"
        >
          <el-select
            v-model="teachingDiscussion.teachingDiscussionStatus"
            filterable
            placeholder="请选择"
            style="width: 100%"
          >
            <el-option
              v-for="j in optionsA"
              :key="j.value"
              :label="j.label"
              :value="j.value"
            />
          </el-select>
          <el-form-item
            prop="teachingDiscussionClazzTypeId"
            label="课程类型"
            :label-width="formLabelWidth"
          >
            <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
            <el-select
              v-model="teachingDiscussion.teachingDiscussionClazzTypeId"
              placeholder="请选择"
              filterable
              style="width: 100%"
            >
              <el-option
                v-for="j in ClazzType"
                :key="j.clazzTypeId"
                :value="j.clazzTypeId"
                :label="j.clazzTypeName"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            prop="teachingDiscussionTechnicalTypeId"
            label="技术类型"
            :label-width="formLabelWidth"
          >
            <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
            <el-select
              v-model="teachingDiscussion.teachingDiscussionTechnicalTypeId"
              placeholder="请选择"
              filterable
              style="width: 100%"
            >
              <el-option
                v-for="j in TechnicalType"
                :key="j.technicalTypeId"
                :value="j.technicalTypeId"
                :label="j.technicalTypeName"
              />
            </el-select>
          </el-form-item>
          <!-- <el-form-item prop="teachingDiscussionPostUserId" label="教学讨论发起人" :label-width="formLabelWidth">

            <el-select v-model="teachingDiscussion.teachingDiscussionPostUserId" placeholder="请选择" filterable style="width: 100%;">
              <el-option
                v-for="j in staff"
                :key="j.staffId"
                :value="j.staffId"
                :label="j.String"
              />
            </el-select>
          </el-form-item> -->

          <el-form-item
            prop="teachingDiscussionPrincipalTeacherId"
            label="主责老师"
            :label-width="formLabelWidth"
          >
            <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
            <el-select
              v-model="teachingDiscussion.teachingDiscussionPrincipalTeacherId"
              placeholder="请选择"
              filterable
              style="width: 100%"
            >
              <el-option
                v-for="j in staffPrincipal"
                :key="j.staffId"
                :value="j.staffId"
                :label="j.String"
              />
            </el-select>
          </el-form-item>

          <el-form-item
            prop="teachingDiscussionTeacherId"
            label="授课老师"
            :label-width="formLabelWidth"
          >
            <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
            <el-select
              v-model="teachingDiscussion.teachingDiscussionTeacherId"
              placeholder="请选择"
              filterable
              style="width: 100%"
            >
              <el-option
                v-for="j in staffTeacher"
                :key="j.staffId"
                :value="j.staffId"
                :label="j.String"
              />
            </el-select>
          </el-form-item>

          <el-form-item
            prop="teachingDiscussionTeachingSupervisorId"
            label="教学主管"
            :label-width="formLabelWidth"
          >
            <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
            <el-select
              v-model="
                teachingDiscussion.teachingDiscussionTeachingSupervisorId
              "
              placeholder="请选择"
              filterable
              style="width: 100%"
            >
              <el-option
                v-for="j in staffSupervisor"
                :key="j.staffId"
                :value="j.staffId"
                :label="j.String"
              />
            </el-select>
          </el-form-item>
        </el-form-item>
      </el-form>
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button
          v-if="editType == 2 && this.jurisdiction == '责任教师'"
          type="primary"
          @click="handleUpdate('teachingDiscussion')"
        >修 改</el-button>
        <el-button
          v-if="editType == 1 && this.jurisdiction == '责任教师'"
          type="primary"
          @click="handleAddUser('teachingDiscussion')"
        >添 加</el-button>
      </div>
    </el-dialog>
    <el-dialog
      v-if="this.jurisdiction != '责任教师'"
      title=""
      :close-on-click-modal="false"
      :visible.sync="dialogFormVisible"
      :before-close="handleClose"
    >
      <el-form
        ref="teachingDiscussion"
        :model="teachingDiscussion"
        label-position="top"
        :rules="rules"
      >
        <el-form-item
          prop="teachingDiscussionEventType"
          label="事件类别"
          :label-width="formLabelWidth"
        >
          <el-tag
            type="info"
            effect="plain"
          >
            {{ SJLB }}
          </el-tag>
          <!-- {{ SJLB }} -->

        </el-form-item>

        <el-form-item
          prop="teachingDiscussionEventTitle"
          label="事件标题"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="teachingDiscussion.teachingDiscussionEventTitle"
            autocomplete="off"
            maxlength="20"
            show-word-limit
            style="width: 100%"
            readonly
          />
        </el-form-item>
        <el-form-item
          prop="teachingDiscussionEventDescription"
          label="事件描述"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="teachingDiscussion.teachingDiscussionEventDescription"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
            readonly
          />
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionRelatedPersonnelIDs"
          label="参加人员"
          :label-width="formLabelWidth"
        >
          <el-tag
            v-for="item in CJRY"
            :key="item"
            type="info"
            effect="plain"
          >
            {{ item }}
          </el-tag>
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionSolution"
          label="解决方案"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="teachingDiscussion.teachingDiscussionSolution"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
            readonly
          />
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionExecutionRecord"
          label="执行记录"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="teachingDiscussion.teachingDiscussionExecutionRecord"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
            readonly
          />
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionEventSummary"
          label="事件总结"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="teachingDiscussion.teachingDiscussionEventSummary"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
            readonly
          />
        </el-form-item>
        <el-form-item
          prop="teachingDiscussionStatus"
          label="状态"
          :label-width="formLabelWidth"
        >
          <el-tag
            type="info"
            effect="plain"
          >
            {{ ZT }}
          </el-tag>
        </el-form-item>
        <el-form-item
          prop="teachingDiscussionClazzTypeId"
          label="课程类型"
          :label-width="formLabelWidth"
        >
          <el-tag
            type="info"
            effect="plain"
          >
            {{ KCLX }}
          </el-tag>
        </el-form-item>
        <el-form-item
          prop="teachingDiscussionTechnicalTypeId"
          label="技术类型"
          :label-width="formLabelWidth"
        >
          <el-tag
            type="info"
            effect="plain"
          >
            {{ JSLX }}
          </el-tag>
        </el-form-item>
        <el-form-item
          prop="teachingDiscussionPrincipalTeacherId"
          label="主责老师"
          :label-width="formLabelWidth"
        >
          <el-tag
            type="info"
            effect="plain"
          >
            {{ ZZLS }}
          </el-tag>
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionTeacherId"
          label="授课老师"
          :label-width="formLabelWidth"
        >
          <el-tag
            type="info"
            effect="plain"
          >

            {{ SKLS }}
          </el-tag>
        </el-form-item>

        <el-form-item
          prop="teachingDiscussionTeachingSupervisorId"
          label="教学主管"
          :label-width="formLabelWidth"
        >
          <el-tag
            type="info"
            effect="plain"
          >

            {{ JXZG }}
          </el-tag>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import { addplans, deleteplans, updateplans } from '@/api/plans'
import {
  getAll,
  getAllteachingDiscussion,
  getteachingDiscussionById,
  getAllteachingDiscussionByDirector,
  getAllteachingDiscussionByprincipal,
  updateplansByprincipal,
  getAllteachingDiscussionAAA,
  adddiscuss,
  selectclazzType,
  selectTechnicalType
} from '@/api/teachingDiscussion'

import { getAllParent, selectStudent } from '@/api/child'
import {
  selectstaff,
  selectstaffPrincipal,
  selectstaffTeacher,
  selectstaffSupervisor
} from '@/api/staff'
import store from '@/store/index'
export default {
  data () {
    return {
      /**
       * 这里是关于非可编辑者的临时变量
       */
      SJLB: '',
      CJRY: [],
      ZT: '',
      KCLX: '',
      JSLX: '',
      ZZLS: '',
      SKLS: '',
      JXZG: '',
      // 以上
      jurisdiction: '',
      BB: store.getters.userId,
      options: [
        {
          value: 0,
          label: '计划调整'
        },
        {
          value: 1,
          label: '方案改进'
        },
        {
          value: 2,
          label: '寻求帮助'
        },
        {
          value: 3,
          label: '其他'
        }
      ],
      value: '',
      newteachingDiscussion: {},

      optionsA: [
        {
          value: 0,
          label: '发起'
        },
        {
          value: 1,
          label: '准备'
        },
        {
          value: 2,
          label: '执行'
        },
        {
          value: 3,
          label: '结束'
        }
      ],
      valueA: '',

      currentPage: 1, // 默认显示页面为1
      pagesize: 5, //    每页的数据条数
      // list: [],
      teachingDiscussionParticipants: '',
      teachingDiscussionRelatedPersonnelIDs: '',
      tableList: [],
      searchTableInfo: '',
      teachingDiscussion: {},
      listLoading: false,
      dialogFormVisible: false,
      editType: 1, // 1 添加 2 修改
      child: {},
      staff: [],
      formLabelWidth: '200px',
      staffPrincipal: [],
      staffTeacher: [],
      ClazzType: [
        {
          clazzTypeId: 0,
          clazzTypeName: '个训'
        },
        {
          clazzTypeId: 1,
          clazzTypeName: '合训'
        },
        {
          clazzTypeId: 2,
          clazzTypeName: '集体'
        }
      ],
      staffSupervisor: [],
      TechnicalType: [
        {
          technicalTypeId: 1,
          technicalTypeName: '语言'
        },
        {
          technicalTypeId: 2,
          technicalTypeName: '认知'
        },
        {
          technicalTypeId: 3,
          technicalTypeName: '游戏'
        },
        {
          technicalTypeId: 4,
          technicalTypeName: '社交'
        },
        {
          technicalTypeId: 5,
          technicalTypeName: '运动'
        },
        {
          technicalTypeId: 6,
          technicalTypeName: '感统'
        },
        {
          technicalTypeId: 7,
          technicalTypeName: '艺术'
        },
        {
          technicalTypeId: 8,
          technicalTypeName: '融合'
        }
      ],
      teacher: '',
      rules: {
        teachingDiscussionEventType: [
          { required: true, message: '请选择事件类别', trigger: 'blur' }
        ],
        teachingDiscussionEventTitle: [
          { required: true, message: '请输入事件标题', trigger: 'blur' }
        ],
        teachingDiscussionEventDescription: [
          { required: true, message: '请输入事件描述', trigger: 'blur' }
        ],
        teachingDiscussionRelatedPersonnelIDs: [
          { required: true, message: '请选择参加人员', trigger: 'blur' }
        ],
        teachingDiscussionSolution: [
          { required: true, message: '请输入解决方案', trigger: 'blur' }
        ],
        teachingDiscussionExecutionRecord: [
          { required: true, message: '请输入执行记录', trigger: 'blur' }
        ],
        teachingDiscussionEventSummary: [
          { required: true, message: '请输入事件总结', trigger: 'blur' }
        ],
        teachingDiscussionStatus: [
          { required: true, message: '请选择状态', trigger: 'blur' }
        ],
        teachingDiscussionClazzTypeId: [
          { required: true, message: '请选择课程类型', trigger: 'blur' }
        ],
        teachingDiscussionTechnicalTypeId: [
          { required: true, message: '请选择技术类型', trigger: 'blur' }
        ],
        teachingDiscussionPrincipalTeacherId: [
          { required: true, message: '请选择主责老师', trigger: 'blur' }
        ],
        teachingDiscussionTeacherId: [
          { required: true, message: '请选择授课老师', trigger: 'blur' }
        ],
        teachingDiscussionTeachingSupervisorId: [
          { required: true, message: '请选择教学主管', trigger: 'blur' }
        ]
      }
    }
  },
  computed: {
    // 根据计算属性模糊搜索
    list () {
      const searchTableInfo = this.searchTableInfo

      if (searchTableInfo) {
        // filter() 方法创建一个新的数组，新数组中的元素是通过检查指定数组中符合条件的所有元素。
        // 注意： filter() 不会对空数组进行检测。
        // 注意： filter() 不会改变原始数组。
        return this.tableList.filter((data) => {
          // some() 方法用于检测数组中的元素是否满足指定条件;
          // some() 方法会依次执行数组的每个元素：
          // 如果有一个元素满足条件，则表达式返回true , 剩余的元素不会再执行检测;
          // 如果没有满足条件的元素，则返回false。
          // 注意： some() 不会对空数组进行检测。
          // 注意： some() 不会改变原始数组。
          return Object.keys(data).some((key) => {
            // indexOf() 返回某个指定的字符在某个字符串中首次出现的位置，如果没有找到就返回-1；
            // 该方法对大小写敏感！所以之前需要toLowerCase()方法将所有查询到内容变为小写。
            return (
              String(data[key]).toLowerCase().indexOf(searchTableInfo) > -1
            )
          })
        })
      }
      return this.tableList
    }
  },
  created () {
    this.jurisdiction = store.getters.roles[0]

    this.fetchData()
    this.getinfo()
  },
  methods: {
    formatSex: function (row, column, cellValue) {
      if (cellValue === '1') {
        return '女'
      } else if (cellValue === '0') {
        return '男'
      }
    },

    formatAge: function (row, column, cellValue) {
      if (cellValue === -1) {
        return '未填写'
      } else {
        return cellValue
      }
    },
    // 每页下拉显示数据
    handleSizeChange: function (size) {
      this.pagesize = size
    },
    // 点击第几页
    handleCurrentChange: function (currentPage) {
      this.currentPage = currentPage
    },
    getinfo: function () {
      selectStudent().then((resp) => {
        this.child = resp.data.records
      })
      selectstaff().then((resp) => {
        this.staff = resp.data.records
      })
      selectstaffPrincipal().then((resp) => {
        this.staffPrincipal = resp.data.records
        // console.log(this.staffPrincipal)
        // for (let i = 0; i < this.staffPrincipal.length; i++) {
        //   this.staffPrincipal[i].staffId = this.staffPrincipal[i].staffId.toString()
        //   console.log(this.staffPrincipal[i].staffId)
        // }
      })
      selectstaffTeacher().then((resp) => {
        this.staffTeacher = resp.data.records
      })
      selectstaffSupervisor().then((resp) => {
        this.staffSupervisor = resp.data.records
      })
      // selectclazzType().then((resp) => {
      //   this.ClazzType = resp.obj;
      // });

      // selectTechnicalType().then((resp) => {
      //   this.TechnicalType = resp.obj;
      // });
    },
    handleClick (row) { },
    fetchData () {
      this.tableList = []
      this.listLoading = true
      this.teachingDiscussionRelatedPersonnelIDs = ''
      if (this.jurisdiction === '教学主管') {
        getAllteachingDiscussionByDirector(this.BB).then((data) => {
          this.newteachingDiscussion
          for (var i = 0; i < data.data.records.length; i++) {
            this.newteachingDiscussion.clazzTypeName =
              data.data.records[i].teachingDiscussionClazzTypeId
            this.newteachingDiscussion.teachingDiscussionId =
              data.data.records[i].teachingDiscussionId
            this.newteachingDiscussion.technicalTypeName =
              data.data.records[i].teachingDiscussionTechnicalTypeId
            this.newteachingDiscussion.teachingDiscussionTeacherName =
              data.data.records[i].teachingDiscussionTeacherName
            this.newteachingDiscussion.teachingDiscussionPrincipalTeacherName =
              data.data.records[i].teachingDiscussionPrincipalTeacherName
            this.newteachingDiscussion.teachingDiscussionTeachingSupervisorName =
              data.data.records[i].teachingDiscussionTeachingSupervisorName
            this.newteachingDiscussion.teachingDiscussionEventType =
              data.data.records[i].teachingDiscussionEventType
            this.newteachingDiscussion.teachingDiscussionPostUserName =
              data.data.records[i].teachingDiscussionPostUserName
            this.newteachingDiscussion.teachingDiscussionPostTime =
              data.data.records[i].teachingDiscussionPostTime
            this.newteachingDiscussion.teachingDiscussionStatus =
              data.data.records[i].teachingDiscussionStatus
            this.newteachingDiscussion.teachingDiscussionParticipants =
              data.data.records[i].teachingDiscussionParticipants
            this.newteachingDiscussion.instructionalSupervisionStatus =
              data.data.records[i].instructionalSupervisionStatus

            this.tableList.push(this.newteachingDiscussion)
            this.newteachingDiscussion = {}
          }

          this.listLoading = false
        })
      } else if (this.jurisdiction === '教学主任') {
        getAllteachingDiscussionAAA(this.BB).then((data) => {
          this.newteachingDiscussion
          for (var i = 0; i < data.data.records.length; i++) {
            this.newteachingDiscussion.clazzTypeName =
              data.data.records[i].teachingDiscussionClazzTypeId
            this.newteachingDiscussion.teachingDiscussionId =
              data.data.records[i].teachingDiscussionId
            this.newteachingDiscussion.technicalTypeName =
              data.data.records[i].teachingDiscussionTechnicalTypeId
            this.newteachingDiscussion.teachingDiscussionTeacherName =
              data.data.records[i].teachingDiscussionTeacherName
            this.newteachingDiscussion.teachingDiscussionPrincipalTeacherName =
              data.data.records[i].teachingDiscussionPrincipalTeacherName
            this.newteachingDiscussion.teachingDiscussionTeachingSupervisorName =
              data.data.records[i].teachingDiscussionTeachingSupervisorName
            this.newteachingDiscussion.teachingDiscussionEventType =
              data.data.records[i].teachingDiscussionEventType
            this.newteachingDiscussion.teachingDiscussionPostUserName =
              data.data.records[i].teachingDiscussionPostUserName
            this.newteachingDiscussion.teachingDiscussionPostTime =
              data.data.records[i].teachingDiscussionPostTime
            this.newteachingDiscussion.teachingDiscussionStatus =
              data.data.records[i].teachingDiscussionStatus
            this.newteachingDiscussion.teachingDiscussionParticipants =
              data.data.records[i].teachingDiscussionParticipants
            this.newteachingDiscussion.instructionalSupervisionStatus =
              data.data.records[i].instructionalSupervisionStatus

            this.tableList.push(this.newteachingDiscussion)
            this.newteachingDiscussion = {}
          }

          this.listLoading = false
        })
      } else if (this.jurisdiction === '责任教师') {
        getAllteachingDiscussionByprincipal(this.BB).then((data) => {
          this.newteachingDiscussion
          // console.log(data.data.records);
          for (var i = 0; i < data.data.records.length; i++) {
            this.newteachingDiscussion.clazzTypeName =
              data.data.records[i].teachingDiscussionClazzTypeId
            this.newteachingDiscussion.teachingDiscussionId =
              data.data.records[i].teachingDiscussionId
            this.newteachingDiscussion.technicalTypeName =
              data.data.records[i].teachingDiscussionTechnicalTypeId
            this.newteachingDiscussion.teachingDiscussionTeacherName =
              data.data.records[i].teachingDiscussionTeacherName
            this.newteachingDiscussion.teachingDiscussionPrincipalTeacherName =
              data.data.records[i].teachingDiscussionPrincipalTeacherName
            this.newteachingDiscussion.teachingDiscussionTeachingSupervisorName =
              data.data.records[i].teachingDiscussionTeachingSupervisorName
            this.newteachingDiscussion.teachingDiscussionEventType =
              data.data.records[i].teachingDiscussionEventType
            this.newteachingDiscussion.teachingDiscussionPostUserName =
              data.data.records[i].teachingDiscussionPostUserName
            this.newteachingDiscussion.teachingDiscussionPostTime =
              data.data.records[i].teachingDiscussionPostTime
            this.newteachingDiscussion.teachingDiscussionStatus =
              data.data.records[i].teachingDiscussionStatus
            this.newteachingDiscussion.teachingDiscussionRelatedPersonnelIDs =
              data.data.records[i].teachingDiscussionRelatedPersonnelIDs
            this.newteachingDiscussion.instructionalSupervisionStatus =
              data.data.records[i].instructionalSupervisionStatus

            this.tableList.push(this.newteachingDiscussion)
            this.newteachingDiscussion = {}
          }

          this.listLoading = false
        })
      } else if (this.jurisdiction === '教务主任') {
        getAll().then((data) => {
          this.newteachingDiscussion
          for (var i = 0; i < data.data.records.length; i++) {
            this.newteachingDiscussion.clazzTypeName =
              data.data.records[i].teachingDiscussionClazzTypeId
            this.newteachingDiscussion.teachingDiscussionId =
              data.data.records[i].teachingDiscussionId
            this.newteachingDiscussion.technicalTypeName =
              data.data.records[i].teachingDiscussionTechnicalTypeId
            this.newteachingDiscussion.teachingDiscussionTeacherName =
              data.data.records[i].teachingDiscussionTeacherName
            this.newteachingDiscussion.teachingDiscussionPrincipalTeacherName =
              data.data.records[i].teachingDiscussionPrincipalTeacherName
            this.newteachingDiscussion.teachingDiscussionTeachingSupervisorName =
              data.data.records[i].teachingDiscussionTeachingSupervisorName
            this.newteachingDiscussion.teachingDiscussionEventType =
              data.data.records[i].teachingDiscussionEventType
            this.newteachingDiscussion.teachingDiscussionPostUserName =
              data.data.records[i].teachingDiscussionPostUserName
            this.newteachingDiscussion.teachingDiscussionPostTime =
              data.data.records[i].teachingDiscussionPostTime
            this.newteachingDiscussion.teachingDiscussionStatus =
              data.data.records[i].teachingDiscussionStatus
            this.newteachingDiscussion.teachingDiscussionParticipants =
              data.data.records[i].teachingDiscussionParticipants
            this.newteachingDiscussion.instructionalSupervisionStatus =
              data.data.records[i].instructionalSupervisionStatus

            this.tableList.push(this.newteachingDiscussion)
            this.newteachingDiscussion = {}
          }

          this.listLoading = false
        })
      } else {
        getAllteachingDiscussion(this.BB).then((data) => {
          this.newteachingDiscussion
          for (var i = 0; i < data.data.records.length; i++) {
            this.newteachingDiscussion.clazzTypeName =
              data.data.records[i].teachingDiscussionClazzTypeId
            this.newteachingDiscussion.teachingDiscussionId =
              data.data.records[i].teachingDiscussionId
            this.newteachingDiscussion.technicalTypeName =
              data.data.records[i].teachingDiscussionTechnicalTypeId
            this.newteachingDiscussion.teachingDiscussionTeacherName =
              data.data.records[i].teachingDiscussionTeacherName
            this.newteachingDiscussion.teachingDiscussionPrincipalTeacherName =
              data.data.records[i].teachingDiscussionPrincipalTeacherName
            this.newteachingDiscussion.teachingDiscussionTeachingSupervisorName =
              data.data.records[i].teachingDiscussionTeachingSupervisorName
            this.newteachingDiscussion.teachingDiscussionEventType =
              data.data.records[i].teachingDiscussionEventType
            this.newteachingDiscussion.teachingDiscussionPostUserName =
              data.data.records[i].teachingDiscussionPostUserName
            this.newteachingDiscussion.teachingDiscussionPostTime =
              data.data.records[i].teachingDiscussionPostTime
            this.newteachingDiscussion.teachingDiscussionStatus =
              data.data.records[i].teachingDiscussionStatus
            this.newteachingDiscussion.teachingDiscussionParticipants =
              data.data.records[i].teachingDiscussionParticipants
            this.newteachingDiscussion.instructionalSupervisionStatus =
              data.data.records[i].instructionalSupervisionStatus

            this.tableList.push(this.newteachingDiscussion)
            this.newteachingDiscussion = {}
          }

          this.listLoading = false
        })
      }
    },
    handleDelete (id) {
      this.$confirm('确认删除该记录？').then(() =>
        deleteplans(id).then((data) => {
          this.$notify({
            title: '操作成功',
            type: 'success'
          })
          const totalPage = Math.ceil(
            (this.tableList.length - 1) / this.pagesize
          )
          const page =
            this.currentPage > totalPage ? totalPage : this.currentPage
          this.currentPage = this.currentPage < 1 ? 1 : page
          this.fetchData()
        })
      )
    },
    handleAddUser (formName) {
      this.$refs[formName].validate((valid) => {
        // console.log(this.teachingDiscussion)
        if (valid) {
          for (
            var i = 0;
            i <
            this.teachingDiscussion.teachingDiscussionRelatedPersonnelIDs
              .length;
            i++
          ) {
            this.teachingDiscussionRelatedPersonnelIDs +=
              this.teachingDiscussion.teachingDiscussionRelatedPersonnelIDs[i] +
              ';'
          }
          this.teachingDiscussion.teachingDiscussionRelatedPersonnelIDs = this.teachingDiscussionRelatedPersonnelIDs

          adddiscuss(this.teachingDiscussion, this.BB).then((resp) => {
            this.$notify({
              title: '操作成功',
              type: 'success'
            })
            this.fetchData()
          })
          this.teachingDiscussion = {}
          this.dialogFormVisible = false
          return true
        } else {
          this.$notify({
            title: '请正确填写',
            type: 'error'
          })
          return false
        }
      })
    },

    handleOpen (title, type, id) {
      this.teachingDiscussion = {}
      this.title = title
      this.editType = type
      if (type === 2) {
        getteachingDiscussionById(id).then((resp) => {
          this.teachingDiscussion = resp.data.records
          this.teachingDiscussionEventType = String(
            resp.data.records.teachingDiscussionEventType
          )
          var list = this.teachingDiscussion.teachingDiscussionRelatedPersonnelIDs
            .toString()
            .split(',')
          for (var i = 0; i < list.length; i++) {
            list[i] = parseInt(list[i])
          }
          // console.log("这是改变之后的list", this.teachingDiscussion);
          this.teachingDiscussion.teachingDiscussionParticipants = list
          if (this.jurisdiction != '主责老师') {
            this.teachingDiscussion.teachingDiscussionEventType
            for (let i1 = 0; i1 < this.options.length; i1++) {
              if (
                this.teachingDiscussion.teachingDiscussionEventType ==
                this.options[i1].value
              ) {
                // console.log(this.options[i1].label);
                this.SJLB = this.options[i1].label
              }
            }
            // console.log(
            //   this.teachingDiscussion.teachingDiscussionRelatedPersonnelIDs
            // );
            // console.log(this.staff);
            for (let i2 = 0; i2 < this.staff.length; i2++) {
              for (
                let j2 = 0;
                j2 <
                this.teachingDiscussion.teachingDiscussionRelatedPersonnelIDs
                  .length;
                j2++
              ) {
                if (
                  this.teachingDiscussion.teachingDiscussionRelatedPersonnelIDs[
                  j2
                  ] == this.staff[i2].staffId
                ) {
                  this.CJRY.push(this.staff[i2].String)
                }
              }
            }
            for (let i3 = 0; i3 < this.optionsA.length; i3++) {
              if (this.teachingDiscussion.teachingDiscussionStatus == this.optionsA[i3].value) {
                this.ZT = this.optionsA[i3].label
              }
            }
            for (let i4 = 0; i4 < this.ClazzType.length; i4++) {
              if (this.teachingDiscussion.teachingDiscussionClazzTypeId == this.ClazzType[i4].clazzTypeId) {
                this.KCLX = this.ClazzType[i4].clazzTypeName
              }
            }
            for (let i5 = 0; i5 < this.TechnicalType.length; i5++) {
              if (this.teachingDiscussion.teachingDiscussionTechnicalTypeId == this.TechnicalType[i5].technicalTypeId) {
                this.JSLX = this.TechnicalType[i5].technicalTypeName
              }
            }
            for (let i6 = 0; i6 < this.staffPrincipal.length; i6++) {
              if (this.teachingDiscussion.teachingDiscussionPrincipalTeacherId == this.staffPrincipal[i6].staffId) {
                this.ZZLS = this.staffPrincipal[i6].String
              }
            }
            for (let i7 = 0; i7 < this.staffTeacher.length; i7++) {
              if (this.teachingDiscussion.teachingDiscussionTeacherId == this.staffTeacher[i7].staffId) {
                this.SKLS = this.staffTeacher[i7].String
              }
            }
            for (let i8 = 0; i8 < this.staffSupervisor.length; i8++) {
              if (this.teachingDiscussion.teachingDiscussionTeachingSupervisorId == this.staffSupervisor[i8].staffId) {
                this.JXZG = this.staffSupervisor[i8].String
              }
            }
          }
        })
        this.dialogFormVisible = true
      } else {
        this.dialogFormVisible = true
      }
    },
    handleClose () {
      this.dialogFormVisible = false
      this.teachingDiscussion = {}
    },
    handleUpdate (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          for (
            var i = 0;
            i < this.teachingDiscussion.teachingDiscussionParticipants.length;
            i++
          ) {
            this.teachingDiscussionParticipants +=
              this.teachingDiscussion.teachingDiscussionParticipants[i] + ';'
          }
          this.teachingDiscussion.teachingDiscussionParticipants = this.teachingDiscussionParticipants

          updateplansByprincipal(this.teachingDiscussion)
            .then((resp) => {
              this.teachingDiscussionRelatedPersonnelIDs = ''
              this.$notify({
                title: '修改成功',
                type: 'success'
              })
              this.fetchData()
            })
            .catch((resp) => {
              this.fetchData()
            })
          this.dialogFormVisible = false
          return true
        } else {
          this.$notify({
            title: '请正确填写',
            type: 'error'
          })
          return false
        }
      })
    },
    technicalTypeName_toString (row, column, cellValue) {
      // console.log(this.TechnicalType)
      for (let i = 0; i < this.TechnicalType.length; i++) {
        if (cellValue == this.TechnicalType[i].technicalTypeId - 1) {
          return this.TechnicalType[i].technicalTypeName
        }
      }
    },
    clazzTypeName_toString (row, column, cellValue) {
      // console.log(this.ClazzType)
      for (let i = 0; i < this.ClazzType.length; i++) {
        if (cellValue == this.ClazzType[i].clazzTypeId) {
          return this.ClazzType[i].clazzTypeName
        }
      }
    }
    // getAllJurisdiction() {
    //   getAllJurisdiction().then((resp) => {
    //     this.jurisdiction = resp.obj
    //   })
    // },
  }
}
</script>

<style scoped>
#main {
  margin-left: 5px;
  margin-right: 5px;
}
#table-area {
  margin-left: 10px;
  margin-right: 10px;
}
</style>
